package com.etc.service.impl;

import com.etc.entity.Permission;
import com.etc.entity.Role;
import com.etc.entity.User;
import com.etc.mapper.GoodsMapper;
import com.etc.mapper.UserPermissionMapper;
import com.etc.service.ShiorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service("shior")
public class ShiorServiceimpl implements ShiorService {

    @Autowired
    private GoodsMapper goodsMapper;
    @Autowired
    private UserPermissionMapper userPermissionMapper;

    public User FindByusername(String username) {
        return userPermissionMapper.FindPasswordByname(username);
    }
    public String FindRole(String username){
        return userPermissionMapper.GetRole(username);
    }
    public List<Permission> FindPermission(String username){
        return userPermissionMapper.FindPermission(username).getPermissionList();
    }

    @Override
    public User LoginSuccess(String username, String password) {
        return userPermissionMapper.LoginSuccess(username,password);
    }

    @Override
    public void register(User user) {
        Date date = new Date();
        user.setPdate(date);
        userPermissionMapper.register(user);
    }

    @Override
    public List<User> quaryall() {
        return userPermissionMapper.quaryall();
    }

    @Override
    public String GetRole(String username) {
        return userPermissionMapper.GetRole(username);
    }

    @Override
    public void delete(int uid) {
        userPermissionMapper.delete(uid);
    }

    @Override
    public void update(User user) {
        userPermissionMapper.update(user);
    }

    @Override
    public int count() {
        return userPermissionMapper.count();
    }

    @Override
    public List<User> query(User user) {
        return userPermissionMapper.query(user);
    }

    @Override
    public List<User> fenyequery(int size, int current) {
        return userPermissionMapper.fenyequery(size,current);
    }

    @Override
    public List<Role> roles() {
        return userPermissionMapper.roles();
    }

    @Override
    public List<User> userlist(User user) {
        return userPermissionMapper.userlist(user);
    }

    @Override
    public Role rolebyname(String rolename) {
        return userPermissionMapper.rolebyname(rolename);
    }

    @Override
    public User FindUser(int userid) {
        return userPermissionMapper.FindUser(userid);
    }

    @Override
    public int countsearch(User user) {
        return userPermissionMapper.countsearch(user);
    }

    @Override
    public User FindPasswordByname(String username) {
        return userPermissionMapper.FindPasswordByname(username);
    }

    @Override
    public User FindPasswordByphone(String phone) {
        return userPermissionMapper.FindPasswordByphone(phone);
    }


}
